<%--
 *  File:    CorrespondDictionary.jsp
 *  @Author: Kent Zhong
 *  Date:    2002/05/07
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.SysDictionary");
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "COM";
  	String strTableName = "v_dicrelation";
	String privilegeCode = "A01000";
	String contextPath = request.getContextPath();
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	cat.debug("The userinfo is :"+CurUserInfo);
  	cat.info("enter my page");
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%int LangNums = ConstantProp.multiLangNumber;%>
<html>
<style type="text/css">
<!--
body{
	margin:0;padding:0;
}
.div1 {
clear: both;
float:left;
height:10px;
border: 0px solid #EEEEEE;
padding:0px;
margin:0px 0px 0px 0px;
}
.div2 {
clear: both;
height:10px;
float:left;
}
.div3 {
clear: both;
height:10px;
float:left;
}
-->
</style>
<head>
<title>CorrespondDictionary.jsp</title>
<PageFlow:CheckPageFlow pageName="p_dicrelation"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/SummaryDivision.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript" >

    function page_typechange()
    {
      page_summary("search");
    }

function page_add()
    {
	    var dicrelationtype=document.cform.dicrelationtype.value;
	    if(!isEmpty(dicrelationtype)){
	      document.cform.processtype.value=eval("document.cform.zylprocesstype1").value;
	    }
	    if (!checkForm(cform)) return;
	    document.cform.dictype.value=document.cform.type.value;
	    /*
   	    var source = eval("cform.type");
        syncChange(source, "type", 0, <%=LangNums%>);
        */
	    cform.actionname.value = "add";
	    cform.target = "_self";
	    isRunning = true;
	    cform.submit();
}
  function page_save()
  {
    sysdictionarysummaryform.actionname.value = "save";
    sysdictionarysummaryform.target = "_self";
    isRunning = true;
    sysdictionarysummaryform.submit();
  }

  function page_delete()
  {
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
  }

  function page_summary(actionvalue,orderbyname)
	{
	  var zyldicrelationtype=document.cform.zyldicrelationtype.value;
	  if(!isEmpty(zyldicrelationtype)){
	      document.cform.zylprocesstype.value=eval("document.cform.zprocesstype"+zyldicrelationtype).value;
	  }
	  var editform = summaryPrepare(cform,actionvalue,orderbyname);
	  editform.action = "CorrespondDictionary.jsp?<%= OvalTools.randomURL() %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();
	}
var popwindow;
function page_selectDic(){
    var type=document.cform.type.value;
    if(isEmpty(type)) {
      alert("请选择字典类型！");
      document.cform.type.focus();
      return;
    }
	var url = "<%=contextPath%>/zylprocessgoals/DicSelect.jsp?type="+type+"&<%= OvalTools.randomURL()%>";
	var windowAttribute = "height=250, width=400,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
  	if(popwindow!=null) popwindow.close();
  	 popwindow = window.open(url,null,windowAttribute);
}

function page_setdic(id,value,valuename){
	var frm = document.cform;
	//frm.prodids.value = id;
	frm.dicvaluename.value = valuename;
	frm.dicvalue.value = value;
}
function showdiv(){
  var dicrelationtype=document.cform.dicrelationtype.value;
  document.getElementById("div1").style.display="none";
  document.getElementById("div2").style.display="none";
  document.getElementById("div3").style.display="none";
  if(!isEmpty(dicrelationtype)){
    document.getElementById("div"+dicrelationtype).style.display="block";
  }
}
function showdiv1(){
  var zyldicrelationtype=document.cform.zyldicrelationtype.value;
  document.getElementById("zdiv1").style.display="none";
  document.getElementById("zdiv2").style.display="none";
  document.getElementById("zdiv3").style.display="none";
  if(!isEmpty(zyldicrelationtype)){
    document.getElementById("zdiv"+zyldicrelationtype).style.display="block";
  }
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="../Dispatcher"  target="_parent">
  <input type="hidden" name="pagename" value="p_dicrelation">
  <input type="hidden" name="actionname">
  <input type="hidden" name="nullstring">
  <input type="hidden" name="orgcode" value="<%=JspHelper.filterNull(CurUserInfo.get("orgcode"))%>">

<%@ include file="/inc/PageLocation.inc" %>
<%
    Vector dicrelationsummary=(Vector)pageContext.getAttribute("dicrelationsummary");
    if(dicrelationsummary==null)
    {
    	dicrelationsummary=new Vector();
    }
    Vector alltype=(Vector)pageContext.getAttribute("alltype");
    if(alltype==null)
    {
        alltype=new Vector();
    }
    String strType=(String)pageContext.getAttribute("type");

    if(strType==null)
    {
        strType="";

    }

    cat.debug("strType is :"+strType);
    cat.debug("sysdictionarysummary is:"+dicrelationsummary);
    cat.debug("alltype is:"+alltype);
%>

<table width="100%" border="0" cellspacing="0">
  <tr>
    <td class="summary_top" colspan="2" ></td>
  </tr>
  <tr>
       <table>
        <td><%=label.getLabelName("L_Type")%></td>
        <td><custom:selectdic property="zyldicrelationtype" dictType="DicrelationType" defaultValueCost="" defaultValue="--------------"  valueCriteria="1,2"/></td><!-- onchange="showdiv1()" -->
        <td><%=label.getLabelName("L_DicType")%></td>
        <td><custom:select  optionsName="alltype" optionValueKey="dictionarytypecode" optionInnerTextKey="description"	property="zyltype"  defaultValueCost="" defaultValue="--------------" /></td>
        <td><%=label.getLabelName("L_CollateType")%></td>
        <td>
          <div  id="zdiv1" class="div1">
	       <custom:selectdic  property="zprocesstype1" dictType="HProcessType"  defaultValue="--------------" defaultValueCost=""/>
	      </div>
	      <div style="display:none;" id="zdiv2" class="div2">
	      	<custom:selectdic property="zprocesstype2" dictType="PProcessType"  defaultValue="--------------" defaultValueCost=""/>
	      </div>
	      <div style="display:none;" id="zdiv3" class="div3">
	      <custom:selectdic   property="zprocesstype3" dictType="DProcessType"  defaultValue="--------------" defaultValueCost=""/>
	      </div>
	      <custom:hidden property="zylprocesstype"/>
        </td>
        <td><a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
       </table>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
          <td width="5%"  class="title_center">&nbsp;</td>
          <td width="15%" class="title_center"><%=label.getLabelName("L_Type")%><span class='red'>*</span></td>
          <td width="15%" class="title_center"><%=label.getLabelName("L_Department")%><span class='red'>*</span></td>
          <td width="25%" class="title_center"><%=label.getLabelName("L_DicType")%><span class='red'>*</span></td>
          <td width="15%" class="title_center"><%=label.getLabelName("L_ValueName")%><span class='red'>*</span></td>
          <td class="15%" class="title_center"><%=label.getLabelName("L_CollateType")%><span class='red'>*</span></td>
        </tr>
         <%
            	int i = 0;
             	String strClassType = new String();
          	%>
	         <logic:iterate id="onerow" collection="<%= dicrelationsummary %>" indexId="idx">
	           	<%
	            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
	           	    Integer dicrelationtype=(Integer)tempMap.get("dicrelationtype");
	            	if(i%2 == 1)
	            	{
	              		strClassType = "td-listrom";
	            	}else{
	              		strClassType = "";
	            	}
	            	i++;
	          	%>
	          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
	          		<td>
	              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("dicrelationid") )%>" class="checkbox">
	            	</td>
	            	<td>
	            		<custom:write name="onerow" property="dicrelationtype" dictType="DicrelationType" nbsp="true"/>
	            	</td>
	            	<td><custom:write name="onerow" property="deptname" nbsp="true"  /></td>
	                <td>
						<custom:write name="onerow" property="description"  nbsp="true"/>
					</td> 
					<td>
						<custom:write name="onerow" property="dicvaluenames"  nbsp="true"/>
					</td> 
	     		    <td>
	     		        <custom:write name="onerow" property="processtype" dictType="HProcessType" nbsp="true"/>
	     		        <custom:hidden name="onerow" property="processtype" colIndex="<%= idx %>"/>
	     		    </td>
	     		 </tr>
	     	 </logic:iterate>
       <tr class="none">
	           <td>&nbsp;</td>
	           <td>
	           	<custom:selectdic name="newhash" property="dicrelationtype" dictType="DicrelationType" command="notnull" label="L_Type" defaultValueCost=" " defaultValue="--------------"  valueCriteria="1,2"/><!-- onchange ="showdiv()" -->
	           </td>
	           <td><custom:select name="newhash" command="notnull" optionsName="alldeptnames" optionValueKey="deptid" optionInnerTextKey="deptname"	property="deptid"  defaultValue="----" defaultValueCost=" " label="L_Dept"/></td>
	            <td>
                 <custom:select name="newhash" command="notnull" optionsName="alltype" optionValueKey="dictionarytypecode" optionInnerTextKey="description"	property="type"  defaultValue="----" defaultValueCost=" " label="L_DicType"/>
	             <custom:hidden name="newhash" property="dictype" />
	           </td>
	           <td>
	           	<custom:text property="dicvaluename" command="notnull" label="L_ValueName" ></custom:text>
				<a onclick="page_selectDic();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
				<custom:hidden name="newhash" property="dicvalue" />
	           </td>
	           <td>
	            <div  id="div1" class="div1">
	           	<custom:selectdic name="newhash" property="zylprocesstype1" dictType="HProcessType"  defaultValue="--------------" defaultValueCost=" "/>
	            </div>
	            <div style="display:none;" id="div2" class="div2">
	           	<custom:selectdic name="newhash" property="zylprocesstype2" dictType="PProcessType"  defaultValue="--------------" defaultValueCost=" "/>
	            </div>
	            <div style="display:none;" id="div3" class="div3">
	           	<custom:selectdic name="newhash" property="zylprocesstype3" dictType="DProcessType"  defaultValue="--------------" defaultValueCost=" "/>
	            </div>
	            <custom:hidden property="processtype" command="notnull" label="L_CollateType"/>
	            &nbsp;
	           </td>
		     </tr>
        <tr>
          <td colspan="6">
            <%@ include file="/inc/SummaryAction.inc" %>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top" ></td>
        </tr>
        <tr>
          <td class="td_center">
          <a onclick="page_add();"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
          <%
          if(dicrelationsummary.size() >0 ){
          %>
          <%--<a onclick="page_save();"><custom:button type="1" label="L_Save" imgsrc="save.gif" border="0" style="width:60"/></a> --%>
          <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
          <%}%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>


